<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg10.php" ?>
<?php include_once "ewmysql10.php" ?>
<?php include_once "phpfn10.php" ?>
<?php include_once "solicitudesinfo.php" ?>
<?php include_once "usuariosinfo.php" ?>
<?php include_once "solicituddetallegridcls.php" ?>
<?php include_once "userfn10.php" ?>
<?php

//
// Page class
//

$solicitudes_add = NULL; // Initialize page object first

class csolicitudes_add extends csolicitudes {

	// Page ID
	var $PageID = 'add';

	// Project ID
	var $ProjectID = "{F232ADC5-E4A2-4026-8F03-D0514C19EE8E}";

	// Table name
	var $TableName = 'solicitudes';

	// Page object name
	var $PageObjName = 'solicitudes_add';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		if ($this->UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	function getWarningMessage() {
		return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
	}

	function setWarningMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
	}

	// Show message
	function ShowMessage() {
		$hidden = FALSE;
		$html = "";

		// Message
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sMessage . "</div>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$sWarningMessage = $this->getWarningMessage();
		$this->Message_Showing($sWarningMessage, "warning");
		if ($sWarningMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sWarningMessage;
			$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
			$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sSuccessMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sErrorMessage;
			$html .= "<div class=\"alert alert-error ewError\">" . $sErrorMessage . "</div>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo "<table class=\"ewStdTable\"><tr><td><div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div></td></tr></table>";
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p>" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Footer exists, display
			echo "<p>" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm;
		if ($this->UseTokenInUrl) {
			if ($objForm)
				return ($this->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($this->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;
		$GLOBALS["Page"] = &$this;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Parent constuctor
		parent::__construct();

		// Table object (solicitudes)
		if (!isset($GLOBALS["solicitudes"]) || get_class($GLOBALS["solicitudes"]) == "csolicitudes") {
			$GLOBALS["solicitudes"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["solicitudes"];
		}

		// Table object (usuarios)
		if (!isset($GLOBALS['usuarios'])) $GLOBALS['usuarios'] = new cusuarios();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'add', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'solicitudes', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();

		// Open connection
		if (!isset($conn)) $conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanAdd()) {
			$Security->SaveLastUrl();
			$this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission
			$this->Page_Terminate("solicitudeslist.php");
		}

		// Create form object
		$objForm = new cFormObj();
		$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up curent action

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();
		$this->Page_Redirecting($url);

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $DbMasterFilter = "";
	var $DbDetailFilter = "";
	var $Priv = 0;
	var $OldRecordset;
	var $CopyRecord;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError;

		// Process form if post back
		if (@$_POST["a_add"] <> "") {
			$this->CurrentAction = $_POST["a_add"]; // Get form action
			$this->CopyRecord = $this->LoadOldRecord(); // Load old recordset
			$this->LoadFormValues(); // Load form values
		} else { // Not post back

			// Load key values from QueryString
			$this->CopyRecord = TRUE;
			if (@$_GET["solicitudID"] != "") {
				$this->solicitudID->setQueryStringValue($_GET["solicitudID"]);
				$this->setKey("solicitudID", $this->solicitudID->CurrentValue); // Set up key
			} else {
				$this->setKey("solicitudID", ""); // Clear key
				$this->CopyRecord = FALSE;
			}
			if ($this->CopyRecord) {
				$this->CurrentAction = "C"; // Copy record
			} else {
				$this->CurrentAction = "I"; // Display blank record
				$this->LoadDefaultValues(); // Load default values
			}
		}

		// Set up Breadcrumb
		$this->SetupBreadcrumb();

		// Set up detail parameters
		$this->SetUpDetailParms();

		// Validate form if post back
		if (@$_POST["a_add"] <> "") {
			if (!$this->ValidateForm()) {
				$this->CurrentAction = "I"; // Form error, reset action
				$this->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues(); // Restore form values
				$this->setFailureMessage($gsFormError);
			}
		}

		// Perform action based on action code
		switch ($this->CurrentAction) {
			case "I": // Blank record, no action required
				break;
			case "C": // Copy an existing record
				if (!$this->LoadRow()) { // Load record based on key
					if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("solicitudeslist.php"); // No matching record, return to list
				}

				// Set up detail parameters
				$this->SetUpDetailParms();
				break;
			case "A": // Add new record
				$this->SendEmail = TRUE; // Send email on add success
				if ($this->AddRow($this->OldRecordset)) { // Add successful
					if ($this->getSuccessMessage() == "")
						$this->setSuccessMessage($Language->Phrase("AddSuccess")); // Set up success message
					if ($this->getCurrentDetailTable() <> "") // Master/detail add
						$sReturnUrl = $this->GetDetailUrl();
					else
						$sReturnUrl = $this->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "solicitudesview.php")
						$sReturnUrl = $this->GetViewUrl(); // View paging, return to view page with keyurl directly
					$this->Page_Terminate($sReturnUrl); // Clean up and return
				} else {
					$this->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Add failed, restore form values

					// Set up detail parameters
					$this->SetUpDetailParms();
				}
		}

		// Render row based on row type
		$this->RowType = EW_ROWTYPE_ADD;  // Render add type

		// Render row
		$this->ResetAttrs();
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm;

		// Get upload data
	}

	// Load default values
	function LoadDefaultValues() {
		$this->solicitudTipo->CurrentValue = NULL;
		$this->solicitudTipo->OldValue = $this->solicitudTipo->CurrentValue;
		$this->solicitudFecha->CurrentValue = NULL;
		$this->solicitudFecha->OldValue = $this->solicitudFecha->CurrentValue;
		$this->solicitudFechaPlanificada->CurrentValue = NULL;
		$this->solicitudFechaPlanificada->OldValue = $this->solicitudFechaPlanificada->CurrentValue;
		$this->solicitudAutor->CurrentValue = NULL;
		$this->solicitudAutor->OldValue = $this->solicitudAutor->CurrentValue;
		$this->solicitudSucursal->CurrentValue = NULL;
		$this->solicitudSucursal->OldValue = $this->solicitudSucursal->CurrentValue;
		$this->solicitudOrigen->CurrentValue = NULL;
		$this->solicitudOrigen->OldValue = $this->solicitudOrigen->CurrentValue;
		$this->solicitudDestino->CurrentValue = NULL;
		$this->solicitudDestino->OldValue = $this->solicitudDestino->CurrentValue;
		$this->solicitudEstado->CurrentValue = NULL;
		$this->solicitudEstado->OldValue = $this->solicitudEstado->CurrentValue;
		$this->solicitudTratado->CurrentValue = 0;
		$this->solicitudObservacion->CurrentValue = NULL;
		$this->solicitudObservacion->OldValue = $this->solicitudObservacion->CurrentValue;
		$this->solicitudUltimaModificacion->CurrentValue = NULL;
		$this->solicitudUltimaModificacion->OldValue = $this->solicitudUltimaModificacion->CurrentValue;
		$this->solicitudUltimaModificacionUsuario->CurrentValue = NULL;
		$this->solicitudUltimaModificacionUsuario->OldValue = $this->solicitudUltimaModificacionUsuario->CurrentValue;
		$this->solicitudAnterior->CurrentValue = 0;
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm;
		if (!$this->solicitudTipo->FldIsDetailKey) {
			$this->solicitudTipo->setFormValue($objForm->GetValue("x_solicitudTipo"));
		}
		if (!$this->solicitudFecha->FldIsDetailKey) {
			$this->solicitudFecha->setFormValue($objForm->GetValue("x_solicitudFecha"));
			$this->solicitudFecha->CurrentValue = ew_UnFormatDateTime($this->solicitudFecha->CurrentValue, 7);
		}
		if (!$this->solicitudFechaPlanificada->FldIsDetailKey) {
			$this->solicitudFechaPlanificada->setFormValue($objForm->GetValue("x_solicitudFechaPlanificada"));
			$this->solicitudFechaPlanificada->CurrentValue = ew_UnFormatDateTime($this->solicitudFechaPlanificada->CurrentValue, 7);
		}
		if (!$this->solicitudAutor->FldIsDetailKey) {
			$this->solicitudAutor->setFormValue($objForm->GetValue("x_solicitudAutor"));
		}
		if (!$this->solicitudSucursal->FldIsDetailKey) {
			$this->solicitudSucursal->setFormValue($objForm->GetValue("x_solicitudSucursal"));
		}
		if (!$this->solicitudOrigen->FldIsDetailKey) {
			$this->solicitudOrigen->setFormValue($objForm->GetValue("x_solicitudOrigen"));
		}
		if (!$this->solicitudDestino->FldIsDetailKey) {
			$this->solicitudDestino->setFormValue($objForm->GetValue("x_solicitudDestino"));
		}
		if (!$this->solicitudEstado->FldIsDetailKey) {
			$this->solicitudEstado->setFormValue($objForm->GetValue("x_solicitudEstado"));
		}
		if (!$this->solicitudTratado->FldIsDetailKey) {
			$this->solicitudTratado->setFormValue($objForm->GetValue("x_solicitudTratado"));
		}
		if (!$this->solicitudObservacion->FldIsDetailKey) {
			$this->solicitudObservacion->setFormValue($objForm->GetValue("x_solicitudObservacion"));
		}
		if (!$this->solicitudUltimaModificacion->FldIsDetailKey) {
			$this->solicitudUltimaModificacion->setFormValue($objForm->GetValue("x_solicitudUltimaModificacion"));
			$this->solicitudUltimaModificacion->CurrentValue = ew_UnFormatDateTime($this->solicitudUltimaModificacion->CurrentValue, 7);
		}
		if (!$this->solicitudUltimaModificacionUsuario->FldIsDetailKey) {
			$this->solicitudUltimaModificacionUsuario->setFormValue($objForm->GetValue("x_solicitudUltimaModificacionUsuario"));
		}
		if (!$this->solicitudAnterior->FldIsDetailKey) {
			$this->solicitudAnterior->setFormValue($objForm->GetValue("x_solicitudAnterior"));
		}
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm;
		$this->LoadOldRecord();
		$this->solicitudTipo->CurrentValue = $this->solicitudTipo->FormValue;
		$this->solicitudFecha->CurrentValue = $this->solicitudFecha->FormValue;
		$this->solicitudFecha->CurrentValue = ew_UnFormatDateTime($this->solicitudFecha->CurrentValue, 7);
		$this->solicitudFechaPlanificada->CurrentValue = $this->solicitudFechaPlanificada->FormValue;
		$this->solicitudFechaPlanificada->CurrentValue = ew_UnFormatDateTime($this->solicitudFechaPlanificada->CurrentValue, 7);
		$this->solicitudAutor->CurrentValue = $this->solicitudAutor->FormValue;
		$this->solicitudSucursal->CurrentValue = $this->solicitudSucursal->FormValue;
		$this->solicitudOrigen->CurrentValue = $this->solicitudOrigen->FormValue;
		$this->solicitudDestino->CurrentValue = $this->solicitudDestino->FormValue;
		$this->solicitudEstado->CurrentValue = $this->solicitudEstado->FormValue;
		$this->solicitudTratado->CurrentValue = $this->solicitudTratado->FormValue;
		$this->solicitudObservacion->CurrentValue = $this->solicitudObservacion->FormValue;
		$this->solicitudUltimaModificacion->CurrentValue = $this->solicitudUltimaModificacion->FormValue;
		$this->solicitudUltimaModificacion->CurrentValue = ew_UnFormatDateTime($this->solicitudUltimaModificacion->CurrentValue, 7);
		$this->solicitudUltimaModificacionUsuario->CurrentValue = $this->solicitudUltimaModificacionUsuario->FormValue;
		$this->solicitudAnterior->CurrentValue = $this->solicitudAnterior->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();

		// Call Row Selecting event
		$this->Row_Selecting($sFilter);

		// Load SQL based on filter
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn;
		if (!$rs || $rs->EOF) return;

		// Call Row Selected event
		$row = &$rs->fields;
		$this->Row_Selected($row);
		$this->solicitudID->setDbValue($rs->fields('solicitudID'));
		$this->solicitudTipo->setDbValue($rs->fields('solicitudTipo'));
		$this->solicitudFecha->setDbValue($rs->fields('solicitudFecha'));
		$this->solicitudFechaPlanificada->setDbValue($rs->fields('solicitudFechaPlanificada'));
		$this->solicitudAutor->setDbValue($rs->fields('solicitudAutor'));
		$this->solicitudSucursal->setDbValue($rs->fields('solicitudSucursal'));
		$this->solicitudOrigen->setDbValue($rs->fields('solicitudOrigen'));
		$this->solicitudDestino->setDbValue($rs->fields('solicitudDestino'));
		$this->solicitudEstado->setDbValue($rs->fields('solicitudEstado'));
		$this->solicitudActivo->setDbValue($rs->fields('solicitudActivo'));
		$this->solicitudTratado->setDbValue($rs->fields('solicitudTratado'));
		$this->solicitudObservacion->setDbValue($rs->fields('solicitudObservacion'));
		$this->solicitudUltimaModificacion->setDbValue($rs->fields('solicitudUltimaModificacion'));
		$this->solicitudUltimaModificacionUsuario->setDbValue($rs->fields('solicitudUltimaModificacionUsuario'));
		$this->solicitudMotivo->setDbValue($rs->fields('solicitudMotivo'));
		$this->solicitudAnterior->setDbValue($rs->fields('solicitudAnterior'));
	}

	// Load DbValue from recordset
	function LoadDbValues(&$rs) {
		if (!$rs || !is_array($rs) && $rs->EOF) return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->solicitudID->DbValue = $row['solicitudID'];
		$this->solicitudTipo->DbValue = $row['solicitudTipo'];
		$this->solicitudFecha->DbValue = $row['solicitudFecha'];
		$this->solicitudFechaPlanificada->DbValue = $row['solicitudFechaPlanificada'];
		$this->solicitudAutor->DbValue = $row['solicitudAutor'];
		$this->solicitudSucursal->DbValue = $row['solicitudSucursal'];
		$this->solicitudOrigen->DbValue = $row['solicitudOrigen'];
		$this->solicitudDestino->DbValue = $row['solicitudDestino'];
		$this->solicitudEstado->DbValue = $row['solicitudEstado'];
		$this->solicitudActivo->DbValue = $row['solicitudActivo'];
		$this->solicitudTratado->DbValue = $row['solicitudTratado'];
		$this->solicitudObservacion->DbValue = $row['solicitudObservacion'];
		$this->solicitudUltimaModificacion->DbValue = $row['solicitudUltimaModificacion'];
		$this->solicitudUltimaModificacionUsuario->DbValue = $row['solicitudUltimaModificacionUsuario'];
		$this->solicitudMotivo->DbValue = $row['solicitudMotivo'];
		$this->solicitudAnterior->DbValue = $row['solicitudAnterior'];
	}

	// Load old record
	function LoadOldRecord() {

		// Load key values from Session
		$bValidKey = TRUE;
		if (strval($this->getKey("solicitudID")) <> "")
			$this->solicitudID->CurrentValue = $this->getKey("solicitudID"); // solicitudID
		else
			$bValidKey = FALSE;

		// Load old recordset
		if ($bValidKey) {
			$this->CurrentFilter = $this->KeyFilter();
			$sSql = $this->SQL();
			$this->OldRecordset = ew_LoadRecordset($sSql);
			$this->LoadRowValues($this->OldRecordset); // Load row values
		} else {
			$this->OldRecordset = NULL;
		}
		return $bValidKey;
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language;
		global $gsLanguage;

		// Initialize URLs
		// Call Row_Rendering event

		$this->Row_Rendering();

		// Common render codes for all row types
		// solicitudID
		// solicitudTipo
		// solicitudFecha
		// solicitudFechaPlanificada
		// solicitudAutor
		// solicitudSucursal
		// solicitudOrigen
		// solicitudDestino
		// solicitudEstado
		// solicitudActivo
		// solicitudTratado
		// solicitudObservacion
		// solicitudUltimaModificacion
		// solicitudUltimaModificacionUsuario
		// solicitudMotivo
		// solicitudAnterior

		if ($this->RowType == EW_ROWTYPE_VIEW) { // View row

			// solicitudID
			$this->solicitudID->ViewValue = $this->solicitudID->CurrentValue;
			$this->solicitudID->ViewCustomAttributes = "";

			// solicitudTipo
			$this->solicitudTipo->ViewValue = $this->solicitudTipo->CurrentValue;
			$this->solicitudTipo->ViewCustomAttributes = "";

			// solicitudFecha
			$this->solicitudFecha->ViewValue = $this->solicitudFecha->CurrentValue;
			$this->solicitudFecha->ViewValue = ew_FormatDateTime($this->solicitudFecha->ViewValue, 7);
			$this->solicitudFecha->ViewCustomAttributes = "";

			// solicitudFechaPlanificada
			$this->solicitudFechaPlanificada->ViewValue = $this->solicitudFechaPlanificada->CurrentValue;
			$this->solicitudFechaPlanificada->ViewValue = ew_FormatDateTime($this->solicitudFechaPlanificada->ViewValue, 7);
			$this->solicitudFechaPlanificada->ViewCustomAttributes = "";

			// solicitudAutor
			$this->solicitudAutor->ViewValue = $this->solicitudAutor->CurrentValue;
			$this->solicitudAutor->ViewCustomAttributes = "";

			// solicitudSucursal
			$this->solicitudSucursal->ViewValue = $this->solicitudSucursal->CurrentValue;
			$this->solicitudSucursal->ViewCustomAttributes = "";

			// solicitudOrigen
			if (strval($this->solicitudOrigen->CurrentValue) <> "") {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->solicitudOrigen->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudOrigen, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->solicitudOrigen->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->solicitudOrigen->ViewValue = $this->solicitudOrigen->CurrentValue;
				}
			} else {
				$this->solicitudOrigen->ViewValue = NULL;
			}
			$this->solicitudOrigen->ViewCustomAttributes = "";

			// solicitudDestino
			if (strval($this->solicitudDestino->CurrentValue) <> "") {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->solicitudDestino->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudDestino, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->solicitudDestino->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->solicitudDestino->ViewValue = $this->solicitudDestino->CurrentValue;
				}
			} else {
				$this->solicitudDestino->ViewValue = NULL;
			}
			$this->solicitudDestino->ViewCustomAttributes = "";

			// solicitudEstado
			if (strval($this->solicitudEstado->CurrentValue) <> "") {
				switch ($this->solicitudEstado->CurrentValue) {
					case $this->solicitudEstado->FldTagValue(1):
						$this->solicitudEstado->ViewValue = $this->solicitudEstado->FldTagCaption(1) <> "" ? $this->solicitudEstado->FldTagCaption(1) : $this->solicitudEstado->CurrentValue;
						break;
					case $this->solicitudEstado->FldTagValue(2):
						$this->solicitudEstado->ViewValue = $this->solicitudEstado->FldTagCaption(2) <> "" ? $this->solicitudEstado->FldTagCaption(2) : $this->solicitudEstado->CurrentValue;
						break;
					default:
						$this->solicitudEstado->ViewValue = $this->solicitudEstado->CurrentValue;
				}
			} else {
				$this->solicitudEstado->ViewValue = NULL;
			}
			$this->solicitudEstado->ViewCustomAttributes = "";

			// solicitudTratado
			$this->solicitudTratado->ViewValue = $this->solicitudTratado->CurrentValue;
			$this->solicitudTratado->ViewCustomAttributes = "";

			// solicitudObservacion
			$this->solicitudObservacion->ViewValue = $this->solicitudObservacion->CurrentValue;
			$this->solicitudObservacion->ViewCustomAttributes = "";

			// solicitudUltimaModificacion
			$this->solicitudUltimaModificacion->ViewValue = $this->solicitudUltimaModificacion->CurrentValue;
			$this->solicitudUltimaModificacion->ViewValue = ew_FormatDateTime($this->solicitudUltimaModificacion->ViewValue, 7);
			$this->solicitudUltimaModificacion->ViewCustomAttributes = "";

			// solicitudUltimaModificacionUsuario
			if (strval($this->solicitudUltimaModificacionUsuario->CurrentValue) <> "") {
				$sFilterWrk = "`usuariosId`" . ew_SearchString("=", $this->solicitudUltimaModificacionUsuario->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `usuariosId`, `usuariosUsuario` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `usuarios`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudUltimaModificacionUsuario, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->solicitudUltimaModificacionUsuario->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->solicitudUltimaModificacionUsuario->ViewValue = $this->solicitudUltimaModificacionUsuario->CurrentValue;
				}
			} else {
				$this->solicitudUltimaModificacionUsuario->ViewValue = NULL;
			}
			$this->solicitudUltimaModificacionUsuario->ViewCustomAttributes = "";

			// solicitudAnterior
			$this->solicitudAnterior->ViewValue = $this->solicitudAnterior->CurrentValue;
			$this->solicitudAnterior->ViewCustomAttributes = "";

			// solicitudTipo
			$this->solicitudTipo->LinkCustomAttributes = "";
			$this->solicitudTipo->HrefValue = "";
			$this->solicitudTipo->TooltipValue = "";

			// solicitudFecha
			$this->solicitudFecha->LinkCustomAttributes = "";
			$this->solicitudFecha->HrefValue = "";
			$this->solicitudFecha->TooltipValue = "";

			// solicitudFechaPlanificada
			$this->solicitudFechaPlanificada->LinkCustomAttributes = "";
			$this->solicitudFechaPlanificada->HrefValue = "";
			$this->solicitudFechaPlanificada->TooltipValue = "";

			// solicitudAutor
			$this->solicitudAutor->LinkCustomAttributes = "";
			$this->solicitudAutor->HrefValue = "";
			$this->solicitudAutor->TooltipValue = "";

			// solicitudSucursal
			$this->solicitudSucursal->LinkCustomAttributes = "";
			$this->solicitudSucursal->HrefValue = "";
			$this->solicitudSucursal->TooltipValue = "";

			// solicitudOrigen
			$this->solicitudOrigen->LinkCustomAttributes = "";
			$this->solicitudOrigen->HrefValue = "";
			$this->solicitudOrigen->TooltipValue = "";

			// solicitudDestino
			$this->solicitudDestino->LinkCustomAttributes = "";
			$this->solicitudDestino->HrefValue = "";
			$this->solicitudDestino->TooltipValue = "";

			// solicitudEstado
			$this->solicitudEstado->LinkCustomAttributes = "";
			$this->solicitudEstado->HrefValue = "";
			$this->solicitudEstado->TooltipValue = "";

			// solicitudTratado
			$this->solicitudTratado->LinkCustomAttributes = "";
			$this->solicitudTratado->HrefValue = "";
			$this->solicitudTratado->TooltipValue = "";

			// solicitudObservacion
			$this->solicitudObservacion->LinkCustomAttributes = "";
			$this->solicitudObservacion->HrefValue = "";
			$this->solicitudObservacion->TooltipValue = "";

			// solicitudUltimaModificacion
			$this->solicitudUltimaModificacion->LinkCustomAttributes = "";
			$this->solicitudUltimaModificacion->HrefValue = "";
			$this->solicitudUltimaModificacion->TooltipValue = "";

			// solicitudUltimaModificacionUsuario
			$this->solicitudUltimaModificacionUsuario->LinkCustomAttributes = "";
			$this->solicitudUltimaModificacionUsuario->HrefValue = "";
			$this->solicitudUltimaModificacionUsuario->TooltipValue = "";

			// solicitudAnterior
			$this->solicitudAnterior->LinkCustomAttributes = "";
			$this->solicitudAnterior->HrefValue = "";
			$this->solicitudAnterior->TooltipValue = "";
		} elseif ($this->RowType == EW_ROWTYPE_ADD) { // Add row

			// solicitudTipo
			$this->solicitudTipo->EditCustomAttributes = "";
			$this->solicitudTipo->EditValue = ew_HtmlEncode($this->solicitudTipo->CurrentValue);
			$this->solicitudTipo->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudTipo->FldCaption()));

			// solicitudFecha
			$this->solicitudFecha->EditCustomAttributes = "";
			$this->solicitudFecha->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->solicitudFecha->CurrentValue, 7));
			$this->solicitudFecha->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudFecha->FldCaption()));

			// solicitudFechaPlanificada
			$this->solicitudFechaPlanificada->EditCustomAttributes = "";
			$this->solicitudFechaPlanificada->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->solicitudFechaPlanificada->CurrentValue, 7));
			$this->solicitudFechaPlanificada->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudFechaPlanificada->FldCaption()));

			// solicitudAutor
			$this->solicitudAutor->EditCustomAttributes = "";
			$this->solicitudAutor->EditValue = ew_HtmlEncode($this->solicitudAutor->CurrentValue);
			$this->solicitudAutor->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudAutor->FldCaption()));

			// solicitudSucursal
			$this->solicitudSucursal->EditCustomAttributes = "";
			$this->solicitudSucursal->EditValue = ew_HtmlEncode($this->solicitudSucursal->CurrentValue);
			$this->solicitudSucursal->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudSucursal->FldCaption()));

			// solicitudOrigen
			$this->solicitudOrigen->EditCustomAttributes = "";
			if (trim(strval($this->solicitudOrigen->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->solicitudOrigen->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudOrigen, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->solicitudOrigen->EditValue = $arwrk;

			// solicitudDestino
			$this->solicitudDestino->EditCustomAttributes = "";
			if (trim(strval($this->solicitudDestino->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->solicitudDestino->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudDestino, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->solicitudDestino->EditValue = $arwrk;

			// solicitudEstado
			$this->solicitudEstado->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array($this->solicitudEstado->FldTagValue(1), $this->solicitudEstado->FldTagCaption(1) <> "" ? $this->solicitudEstado->FldTagCaption(1) : $this->solicitudEstado->FldTagValue(1));
			$arwrk[] = array($this->solicitudEstado->FldTagValue(2), $this->solicitudEstado->FldTagCaption(2) <> "" ? $this->solicitudEstado->FldTagCaption(2) : $this->solicitudEstado->FldTagValue(2));
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$this->solicitudEstado->EditValue = $arwrk;

			// solicitudTratado
			$this->solicitudTratado->EditCustomAttributes = "";
			$this->solicitudTratado->EditValue = ew_HtmlEncode($this->solicitudTratado->CurrentValue);
			$this->solicitudTratado->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudTratado->FldCaption()));

			// solicitudObservacion
			$this->solicitudObservacion->EditCustomAttributes = "";
			$this->solicitudObservacion->EditValue = ew_HtmlEncode($this->solicitudObservacion->CurrentValue);
			$this->solicitudObservacion->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudObservacion->FldCaption()));

			// solicitudUltimaModificacion
			$this->solicitudUltimaModificacion->EditCustomAttributes = "";
			$this->solicitudUltimaModificacion->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->solicitudUltimaModificacion->CurrentValue, 7));
			$this->solicitudUltimaModificacion->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudUltimaModificacion->FldCaption()));

			// solicitudUltimaModificacionUsuario
			$this->solicitudUltimaModificacionUsuario->EditCustomAttributes = "";
			$sFilterWrk = "";
			$sSqlWrk = "SELECT `usuariosId`, `usuariosUsuario` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `usuarios`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->solicitudUltimaModificacionUsuario, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->solicitudUltimaModificacionUsuario->EditValue = $arwrk;

			// solicitudAnterior
			$this->solicitudAnterior->EditCustomAttributes = "";
			$this->solicitudAnterior->EditValue = ew_HtmlEncode($this->solicitudAnterior->CurrentValue);
			$this->solicitudAnterior->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->solicitudAnterior->FldCaption()));

			// Edit refer script
			// solicitudTipo

			$this->solicitudTipo->HrefValue = "";

			// solicitudFecha
			$this->solicitudFecha->HrefValue = "";

			// solicitudFechaPlanificada
			$this->solicitudFechaPlanificada->HrefValue = "";

			// solicitudAutor
			$this->solicitudAutor->HrefValue = "";

			// solicitudSucursal
			$this->solicitudSucursal->HrefValue = "";

			// solicitudOrigen
			$this->solicitudOrigen->HrefValue = "";

			// solicitudDestino
			$this->solicitudDestino->HrefValue = "";

			// solicitudEstado
			$this->solicitudEstado->HrefValue = "";

			// solicitudTratado
			$this->solicitudTratado->HrefValue = "";

			// solicitudObservacion
			$this->solicitudObservacion->HrefValue = "";

			// solicitudUltimaModificacion
			$this->solicitudUltimaModificacion->HrefValue = "";

			// solicitudUltimaModificacionUsuario
			$this->solicitudUltimaModificacionUsuario->HrefValue = "";

			// solicitudAnterior
			$this->solicitudAnterior->HrefValue = "";
		}
		if ($this->RowType == EW_ROWTYPE_ADD ||
			$this->RowType == EW_ROWTYPE_EDIT ||
			$this->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
			$this->SetupFieldTitles();
		}

		// Call Row Rendered event
		if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckInteger($this->solicitudTipo->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudTipo->FldErrMsg());
		}
		if (!ew_CheckEuroDate($this->solicitudFecha->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudFecha->FldErrMsg());
		}
		if (!ew_CheckEuroDate($this->solicitudFechaPlanificada->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudFechaPlanificada->FldErrMsg());
		}
		if (!ew_CheckInteger($this->solicitudAutor->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudAutor->FldErrMsg());
		}
		if (!ew_CheckInteger($this->solicitudSucursal->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudSucursal->FldErrMsg());
		}
		if (!ew_CheckInteger($this->solicitudTratado->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudTratado->FldErrMsg());
		}
		if (!ew_CheckEuroDate($this->solicitudUltimaModificacion->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudUltimaModificacion->FldErrMsg());
		}
		if (!ew_CheckInteger($this->solicitudAnterior->FormValue)) {
			ew_AddMessage($gsFormError, $this->solicitudAnterior->FldErrMsg());
		}

		// Validate detail grid
		$DetailTblVar = explode(",", $this->getCurrentDetailTable());
		if (in_array("solicituddetalle", $DetailTblVar) && $GLOBALS["solicituddetalle"]->DetailAdd) {
			if (!isset($GLOBALS["solicituddetalle_grid"])) $GLOBALS["solicituddetalle_grid"] = new csolicituddetalle_grid(); // get detail page object
			$GLOBALS["solicituddetalle_grid"]->ValidateGridForm();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			ew_AddMessage($gsFormError, $sFormCustomError);
		}
		return $ValidateForm;
	}

	// Add record
	function AddRow($rsold = NULL) {
		global $conn, $Language, $Security;

		// Begin transaction
		if ($this->getCurrentDetailTable() <> "")
			$conn->BeginTrans();

		// Load db values from rsold
		if ($rsold) {
			$this->LoadDbValues($rsold);
		}
		$rsnew = array();

		// solicitudTipo
		$this->solicitudTipo->SetDbValueDef($rsnew, $this->solicitudTipo->CurrentValue, NULL, FALSE);

		// solicitudFecha
		$this->solicitudFecha->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->solicitudFecha->CurrentValue, 7), NULL, FALSE);

		// solicitudFechaPlanificada
		$this->solicitudFechaPlanificada->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->solicitudFechaPlanificada->CurrentValue, 7), NULL, FALSE);

		// solicitudAutor
		$this->solicitudAutor->SetDbValueDef($rsnew, $this->solicitudAutor->CurrentValue, NULL, FALSE);

		// solicitudSucursal
		$this->solicitudSucursal->SetDbValueDef($rsnew, $this->solicitudSucursal->CurrentValue, NULL, FALSE);

		// solicitudOrigen
		$this->solicitudOrigen->SetDbValueDef($rsnew, $this->solicitudOrigen->CurrentValue, NULL, FALSE);

		// solicitudDestino
		$this->solicitudDestino->SetDbValueDef($rsnew, $this->solicitudDestino->CurrentValue, NULL, FALSE);

		// solicitudEstado
		$this->solicitudEstado->SetDbValueDef($rsnew, $this->solicitudEstado->CurrentValue, NULL, FALSE);

		// solicitudTratado
		$this->solicitudTratado->SetDbValueDef($rsnew, $this->solicitudTratado->CurrentValue, NULL, strval($this->solicitudTratado->CurrentValue) == "");

		// solicitudObservacion
		$this->solicitudObservacion->SetDbValueDef($rsnew, $this->solicitudObservacion->CurrentValue, NULL, FALSE);

		// solicitudUltimaModificacion
		$this->solicitudUltimaModificacion->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->solicitudUltimaModificacion->CurrentValue, 7), NULL, FALSE);

		// solicitudUltimaModificacionUsuario
		$this->solicitudUltimaModificacionUsuario->SetDbValueDef($rsnew, $this->solicitudUltimaModificacionUsuario->CurrentValue, NULL, FALSE);

		// solicitudAnterior
		$this->solicitudAnterior->SetDbValueDef($rsnew, $this->solicitudAnterior->CurrentValue, NULL, strval($this->solicitudAnterior->CurrentValue) == "");

		// Call Row Inserting event
		$rs = ($rsold == NULL) ? NULL : $rsold->fields;
		$bInsertRow = $this->Row_Inserting($rs, $rsnew);
		if ($bInsertRow) {
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$AddRow = $this->Insert($rsnew);
			$conn->raiseErrorFn = '';
			if ($AddRow) {
			}
		} else {
			if ($this->getSuccessMessage() <> "" || $this->getFailureMessage() <> "") {

				// Use the message, do nothing
			} elseif ($this->CancelMessage <> "") {
				$this->setFailureMessage($this->CancelMessage);
				$this->CancelMessage = "";
			} else {
				$this->setFailureMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}

		// Get insert id if necessary
		if ($AddRow) {
			$this->solicitudID->setDbValue($conn->Insert_ID());
			$rsnew['solicitudID'] = $this->solicitudID->DbValue;
		}

		// Add detail records
		if ($AddRow) {
			$DetailTblVar = explode(",", $this->getCurrentDetailTable());
			if (in_array("solicituddetalle", $DetailTblVar) && $GLOBALS["solicituddetalle"]->DetailAdd) {
				$GLOBALS["solicituddetalle"]->detalleSolicitud->setSessionValue($this->solicitudID->CurrentValue); // Set master key
				if (!isset($GLOBALS["solicituddetalle_grid"])) $GLOBALS["solicituddetalle_grid"] = new csolicituddetalle_grid(); // Get detail page object
				$AddRow = $GLOBALS["solicituddetalle_grid"]->GridInsert();
				if (!$AddRow)
					$GLOBALS["solicituddetalle"]->detalleSolicitud->setSessionValue(""); // Clear master key if insert failed
			}
		}

		// Commit/Rollback transaction
		if ($this->getCurrentDetailTable() <> "") {
			if ($AddRow) {
				$conn->CommitTrans(); // Commit transaction
			} else {
				$conn->RollbackTrans(); // Rollback transaction
			}
		}
		if ($AddRow) {

			// Call Row Inserted event
			$rs = ($rsold == NULL) ? NULL : $rsold->fields;
			$this->Row_Inserted($rs, $rsnew);
		}
		return $AddRow;
	}

	// Set up detail parms based on QueryString
	function SetUpDetailParms() {

		// Get the keys for master table
		if (isset($_GET[EW_TABLE_SHOW_DETAIL])) {
			$sDetailTblVar = $_GET[EW_TABLE_SHOW_DETAIL];
			$this->setCurrentDetailTable($sDetailTblVar);
		} else {
			$sDetailTblVar = $this->getCurrentDetailTable();
		}
		if ($sDetailTblVar <> "") {
			$DetailTblVar = explode(",", $sDetailTblVar);
			if (in_array("solicituddetalle", $DetailTblVar)) {
				if (!isset($GLOBALS["solicituddetalle_grid"]))
					$GLOBALS["solicituddetalle_grid"] = new csolicituddetalle_grid;
				if ($GLOBALS["solicituddetalle_grid"]->DetailAdd) {
					if ($this->CopyRecord)
						$GLOBALS["solicituddetalle_grid"]->CurrentMode = "copy";
					else
						$GLOBALS["solicituddetalle_grid"]->CurrentMode = "add";
					$GLOBALS["solicituddetalle_grid"]->CurrentAction = "gridadd";

					// Save current master table to detail table
					$GLOBALS["solicituddetalle_grid"]->setCurrentMasterTable($this->TableVar);
					$GLOBALS["solicituddetalle_grid"]->setStartRecordNumber(1);
					$GLOBALS["solicituddetalle_grid"]->detalleSolicitud->FldIsDetailKey = TRUE;
					$GLOBALS["solicituddetalle_grid"]->detalleSolicitud->CurrentValue = $this->solicitudID->CurrentValue;
					$GLOBALS["solicituddetalle_grid"]->detalleSolicitud->setSessionValue($GLOBALS["solicituddetalle_grid"]->detalleSolicitud->CurrentValue);
				}
			}
		}
	}

	// Set up Breadcrumb
	function SetupBreadcrumb() {
		global $Breadcrumb, $Language;
		$Breadcrumb = new cBreadcrumb();
		$Breadcrumb->Add("list", $this->TableVar, "solicitudeslist.php", $this->TableVar, TRUE);
		$PageId = ($this->CurrentAction == "C") ? "Copy" : "Add";
		$Breadcrumb->Add("add", $PageId, ew_CurrentUrl());
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
<?php ew_Header(FALSE) ?>
<?php

// Create page object
if (!isset($solicitudes_add)) $solicitudes_add = new csolicitudes_add();

// Page init
$solicitudes_add->Page_Init();

// Page main
$solicitudes_add->Page_Main();

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$solicitudes_add->Page_Render();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">

// Page object
var solicitudes_add = new ew_Page("solicitudes_add");
solicitudes_add.PageID = "add"; // Page ID
var EW_PAGE_ID = solicitudes_add.PageID; // For backward compatibility

// Form object
var fsolicitudesadd = new ew_Form("fsolicitudesadd");

// Validate form
fsolicitudesadd.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			elm = this.GetElements("x" + infix + "_solicitudTipo");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudTipo->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudFecha");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudFecha->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudFechaPlanificada");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudFechaPlanificada->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudAutor");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudAutor->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudSucursal");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudSucursal->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudTratado");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudTratado->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudUltimaModificacion");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudUltimaModificacion->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_solicitudAnterior");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($solicitudes->solicitudAnterior->FldErrMsg()) ?>");

			// Set up row object
			ew_ElementsToRow(fobj);

			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}

	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}

// Form_CustomValidate event
fsolicitudesadd.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }

// Use JavaScript validation or not
<?php if (EW_CLIENT_VALIDATE) { ?>
fsolicitudesadd.ValidateRequired = true;
<?php } else { ?>
fsolicitudesadd.ValidateRequired = false; 
<?php } ?>

// Dynamic selection lists
fsolicitudesadd.Lists["x_solicitudOrigen"] = {"LinkField":"x_sucursalId","Ajax":true,"AutoFill":false,"DisplayFields":["x_sucursalNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fsolicitudesadd.Lists["x_solicitudDestino"] = {"LinkField":"x_sucursalId","Ajax":true,"AutoFill":false,"DisplayFields":["x_sucursalNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fsolicitudesadd.Lists["x_solicitudUltimaModificacionUsuario"] = {"LinkField":"x_usuariosId","Ajax":null,"AutoFill":false,"DisplayFields":["x_usuariosUsuario","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};

// Form object for search
</script>
<script type="text/javascript">

// Write your client script here, no need to add script tags.
</script>
<?php $Breadcrumb->Render(); ?>
<?php $solicitudes_add->ShowPageHeader(); ?>
<?php
$solicitudes_add->ShowMessage();
?>
<form name="fsolicitudesadd" id="fsolicitudesadd" class="ewForm form-horizontal" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" value="solicitudes">
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewGrid"><tr><td>
<table id="tbl_solicitudesadd" class="table table-bordered table-striped">
<?php if ($solicitudes->solicitudTipo->Visible) { // solicitudTipo ?>
	<tr id="r_solicitudTipo">
		<td><span id="elh_solicitudes_solicitudTipo"><?php echo $solicitudes->solicitudTipo->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudTipo->CellAttributes() ?>>
<span id="el_solicitudes_solicitudTipo" class="control-group">
<input type="text" data-field="x_solicitudTipo" name="x_solicitudTipo" id="x_solicitudTipo" size="30" placeholder="<?php echo $solicitudes->solicitudTipo->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudTipo->EditValue ?>"<?php echo $solicitudes->solicitudTipo->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudTipo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudFecha->Visible) { // solicitudFecha ?>
	<tr id="r_solicitudFecha">
		<td><span id="elh_solicitudes_solicitudFecha"><?php echo $solicitudes->solicitudFecha->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudFecha->CellAttributes() ?>>
<span id="el_solicitudes_solicitudFecha" class="control-group">
<input type="text" data-field="x_solicitudFecha" name="x_solicitudFecha" id="x_solicitudFecha" placeholder="<?php echo $solicitudes->solicitudFecha->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudFecha->EditValue ?>"<?php echo $solicitudes->solicitudFecha->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudFecha->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudFechaPlanificada->Visible) { // solicitudFechaPlanificada ?>
	<tr id="r_solicitudFechaPlanificada">
		<td><span id="elh_solicitudes_solicitudFechaPlanificada"><?php echo $solicitudes->solicitudFechaPlanificada->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudFechaPlanificada->CellAttributes() ?>>
<span id="el_solicitudes_solicitudFechaPlanificada" class="control-group">
<input type="text" data-field="x_solicitudFechaPlanificada" name="x_solicitudFechaPlanificada" id="x_solicitudFechaPlanificada" placeholder="<?php echo $solicitudes->solicitudFechaPlanificada->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudFechaPlanificada->EditValue ?>"<?php echo $solicitudes->solicitudFechaPlanificada->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudFechaPlanificada->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudAutor->Visible) { // solicitudAutor ?>
	<tr id="r_solicitudAutor">
		<td><span id="elh_solicitudes_solicitudAutor"><?php echo $solicitudes->solicitudAutor->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudAutor->CellAttributes() ?>>
<span id="el_solicitudes_solicitudAutor" class="control-group">
<input type="text" data-field="x_solicitudAutor" name="x_solicitudAutor" id="x_solicitudAutor" size="30" placeholder="<?php echo $solicitudes->solicitudAutor->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudAutor->EditValue ?>"<?php echo $solicitudes->solicitudAutor->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudAutor->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudSucursal->Visible) { // solicitudSucursal ?>
	<tr id="r_solicitudSucursal">
		<td><span id="elh_solicitudes_solicitudSucursal"><?php echo $solicitudes->solicitudSucursal->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudSucursal->CellAttributes() ?>>
<span id="el_solicitudes_solicitudSucursal" class="control-group">
<input type="text" data-field="x_solicitudSucursal" name="x_solicitudSucursal" id="x_solicitudSucursal" size="30" placeholder="<?php echo $solicitudes->solicitudSucursal->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudSucursal->EditValue ?>"<?php echo $solicitudes->solicitudSucursal->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudSucursal->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudOrigen->Visible) { // solicitudOrigen ?>
	<tr id="r_solicitudOrigen">
		<td><span id="elh_solicitudes_solicitudOrigen"><?php echo $solicitudes->solicitudOrigen->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudOrigen->CellAttributes() ?>>
<span id="el_solicitudes_solicitudOrigen" class="control-group">
<select data-field="x_solicitudOrigen" id="x_solicitudOrigen" name="x_solicitudOrigen"<?php echo $solicitudes->solicitudOrigen->EditAttributes() ?>>
<?php
if (is_array($solicitudes->solicitudOrigen->EditValue)) {
	$arwrk = $solicitudes->solicitudOrigen->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($solicitudes->solicitudOrigen->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
$sWhereWrk = "";

// Call Lookup selecting
$solicitudes->Lookup_Selecting($solicitudes->solicitudOrigen, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_solicitudOrigen" id="s_x_solicitudOrigen" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`sucursalId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $solicitudes->solicitudOrigen->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudDestino->Visible) { // solicitudDestino ?>
	<tr id="r_solicitudDestino">
		<td><span id="elh_solicitudes_solicitudDestino"><?php echo $solicitudes->solicitudDestino->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudDestino->CellAttributes() ?>>
<span id="el_solicitudes_solicitudDestino" class="control-group">
<select data-field="x_solicitudDestino" id="x_solicitudDestino" name="x_solicitudDestino"<?php echo $solicitudes->solicitudDestino->EditAttributes() ?>>
<?php
if (is_array($solicitudes->solicitudDestino->EditValue)) {
	$arwrk = $solicitudes->solicitudDestino->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($solicitudes->solicitudDestino->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
$sWhereWrk = "";

// Call Lookup selecting
$solicitudes->Lookup_Selecting($solicitudes->solicitudDestino, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_solicitudDestino" id="s_x_solicitudDestino" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`sucursalId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $solicitudes->solicitudDestino->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudEstado->Visible) { // solicitudEstado ?>
	<tr id="r_solicitudEstado">
		<td><span id="elh_solicitudes_solicitudEstado"><?php echo $solicitudes->solicitudEstado->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudEstado->CellAttributes() ?>>
<span id="el_solicitudes_solicitudEstado" class="control-group">
<select data-field="x_solicitudEstado" id="x_solicitudEstado" name="x_solicitudEstado"<?php echo $solicitudes->solicitudEstado->EditAttributes() ?>>
<?php
if (is_array($solicitudes->solicitudEstado->EditValue)) {
	$arwrk = $solicitudes->solicitudEstado->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($solicitudes->solicitudEstado->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
<?php echo $solicitudes->solicitudEstado->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudTratado->Visible) { // solicitudTratado ?>
	<tr id="r_solicitudTratado">
		<td><span id="elh_solicitudes_solicitudTratado"><?php echo $solicitudes->solicitudTratado->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudTratado->CellAttributes() ?>>
<span id="el_solicitudes_solicitudTratado" class="control-group">
<input type="text" data-field="x_solicitudTratado" name="x_solicitudTratado" id="x_solicitudTratado" size="30" placeholder="<?php echo $solicitudes->solicitudTratado->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudTratado->EditValue ?>"<?php echo $solicitudes->solicitudTratado->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudTratado->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudObservacion->Visible) { // solicitudObservacion ?>
	<tr id="r_solicitudObservacion">
		<td><span id="elh_solicitudes_solicitudObservacion"><?php echo $solicitudes->solicitudObservacion->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudObservacion->CellAttributes() ?>>
<span id="el_solicitudes_solicitudObservacion" class="control-group">
<input type="text" data-field="x_solicitudObservacion" name="x_solicitudObservacion" id="x_solicitudObservacion" size="30" maxlength="255" placeholder="<?php echo $solicitudes->solicitudObservacion->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudObservacion->EditValue ?>"<?php echo $solicitudes->solicitudObservacion->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudObservacion->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudUltimaModificacion->Visible) { // solicitudUltimaModificacion ?>
	<tr id="r_solicitudUltimaModificacion">
		<td><span id="elh_solicitudes_solicitudUltimaModificacion"><?php echo $solicitudes->solicitudUltimaModificacion->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudUltimaModificacion->CellAttributes() ?>>
<span id="el_solicitudes_solicitudUltimaModificacion" class="control-group">
<input type="text" data-field="x_solicitudUltimaModificacion" name="x_solicitudUltimaModificacion" id="x_solicitudUltimaModificacion" placeholder="<?php echo $solicitudes->solicitudUltimaModificacion->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudUltimaModificacion->EditValue ?>"<?php echo $solicitudes->solicitudUltimaModificacion->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudUltimaModificacion->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudUltimaModificacionUsuario->Visible) { // solicitudUltimaModificacionUsuario ?>
	<tr id="r_solicitudUltimaModificacionUsuario">
		<td><span id="elh_solicitudes_solicitudUltimaModificacionUsuario"><?php echo $solicitudes->solicitudUltimaModificacionUsuario->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudUltimaModificacionUsuario->CellAttributes() ?>>
<span id="el_solicitudes_solicitudUltimaModificacionUsuario" class="control-group">
<select data-field="x_solicitudUltimaModificacionUsuario" id="x_solicitudUltimaModificacionUsuario" name="x_solicitudUltimaModificacionUsuario"<?php echo $solicitudes->solicitudUltimaModificacionUsuario->EditAttributes() ?>>
<?php
if (is_array($solicitudes->solicitudUltimaModificacionUsuario->EditValue)) {
	$arwrk = $solicitudes->solicitudUltimaModificacionUsuario->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($solicitudes->solicitudUltimaModificacionUsuario->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<script type="text/javascript">
fsolicitudesadd.Lists["x_solicitudUltimaModificacionUsuario"].Options = <?php echo (is_array($solicitudes->solicitudUltimaModificacionUsuario->EditValue)) ? ew_ArrayToJson($solicitudes->solicitudUltimaModificacionUsuario->EditValue, 1) : "[]" ?>;
</script>
</span>
<?php echo $solicitudes->solicitudUltimaModificacionUsuario->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($solicitudes->solicitudAnterior->Visible) { // solicitudAnterior ?>
	<tr id="r_solicitudAnterior">
		<td><span id="elh_solicitudes_solicitudAnterior"><?php echo $solicitudes->solicitudAnterior->FldCaption() ?></span></td>
		<td<?php echo $solicitudes->solicitudAnterior->CellAttributes() ?>>
<span id="el_solicitudes_solicitudAnterior" class="control-group">
<input type="text" data-field="x_solicitudAnterior" name="x_solicitudAnterior" id="x_solicitudAnterior" size="30" placeholder="<?php echo $solicitudes->solicitudAnterior->PlaceHolder ?>" value="<?php echo $solicitudes->solicitudAnterior->EditValue ?>"<?php echo $solicitudes->solicitudAnterior->EditAttributes() ?>>
</span>
<?php echo $solicitudes->solicitudAnterior->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</td></tr></table>
<?php
	if (in_array("solicituddetalle", explode(",", $solicitudes->getCurrentDetailTable())) && $solicituddetalle->DetailAdd) {
?>
<?php include_once "solicituddetallegrid.php" ?>
<?php } ?>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><?php echo $Language->Phrase("AddBtn") ?></button>
</form>
<script type="text/javascript">
fsolicitudesadd.Init();
<?php if (EW_MOBILE_REFLOW && ew_IsMobile()) { ?>
ew_Reflow();
<?php } ?>
</script>
<?php
$solicitudes_add->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script type="text/javascript">

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$solicitudes_add->Page_Terminate();
?>
